import {getStudentList, getSingleStudent, addStudentApi, addLearnApi, deleteStudentsApi, studentChangeApi, toUpdateApi, newStudentsApi,
        allSectionsApi, enumerationApi, changeRecordApi, monitorApi, getAllGradeApi, handleRelativesApi, unbindApi, correspondingGradeApi} from '@/api/studentListApi'
        import {getGradeList} from '@/api/schoolApi'
const studentLists = {
    namespaced: true,
    state: {
      // 单个学生详细信息。 （ 为用就代表是新增功能过来 ）
      individualStudent: '',
      // 港澳台侨外数组
      oCCompatriotsDataArrS: [],
      // 证件类型数组
      documentTypeDataArrS: [],
      // 民族枚举数组
      nationDataArrS: [],
      // 健康状态枚举数组
      healthyDataArrS: [],
      // 入学方式枚举数组
      entranceDataArrS: [],
      // 户口性质枚举数组
      residenceTypeDataArrS: [],
      // 政治面貌枚举数组
      politicalOutlookDataArrS: [],
      // 学生来源枚举数组
      admissionModeDataArrS: [],
      // 就读方式枚举数组
      modeOfStudyDataArrS: [],
      // 残疾类型枚举数组
      disabilityTypeDataArrS: [],
      // 残疾人随班就读类型枚举数组
      onDutyDataArrS: [],
      // 上下学交通方式
      modeOfTransportationDataArrS: [],
      // 亲属关系枚举数组
      relativesDataArrS: []
    },
    getters: {
    },
    mutations: {
      individualStudentMut (state, val) {
        state.individualStudent = val
      },
      documentTypeDataArrMut (state, val) {
        state.documentTypeDataArrS = val
      },
      nationDataArrMut (state, val) {
        state.nationDataArrS = val
      },
      healthyDataArrMut (state, val) {
        state.healthyDataArrS = val
      },
      entranceDataArrMut (state, val) {
        state.entranceDataArrS = val
      },
      residenceTypeDataArrMut (state, val) {
        state.residenceTypeDataArrS = val
      },
      politicalOutlookDataArrMut (state, val) {
        state.politicalOutlookDataArrS = val
      },
      admissionModeDataArrMut (state, val) {
        state.admissionModeDataArrS = val
      },
      modeOfStudyDataArrMut (state, val) {
        state.modeOfStudyDataArrS = val
      },
      disabilityTypeDataArrMut (state, val) {
        state.disabilityTypeDataArrS = val
      },
      onDutyDataArrMut (state, val) {
        state.onDutyDataArrS = val
      },
      modeOfTransportationDataArrMut (state, val) {
        state.modeOfTransportationDataArrS = val
      },
      relativesDataArrMut (state, val) {
        state.relativesDataArrS = val
      },
      oCCompatriotsDataArrMut (state, val) {
        state.oCCompatriotsDataArrS = val
      }
    },
    actions: {
      // 获取学生列表
      getStudentList ({state, commit, dispatch}, params) {
        return new Promise((resolve, reject) => {
          getStudentList(params).then(res => {
              resolve(res)
          })
        })
      },
      // 获取单个学生信息
      getSingleStudent ({state, commit, dispatch}, params) {
        return new Promise((resolve, reject) => {
          getSingleStudent(params).then(res => {
              resolve(res)
          })
        })
      },
      // 获取所有年级
      getAllGradeApi ({state, commit, dispatch, rootState}, params) {
        return new Promise((resolve, reject) => {
          getGradeList(params).then(res => {
              resolve(res.items)
          })
        })
      },
			// 获取该学校的所有班级
			addStudentApi ({state, commit, dispatch}, params) {
        return new Promise((resolve, reject) => {
          addStudentApi(params).then(res => {
              resolve(res)
          })
        })
      },
      // 获取所有的学届（ 学籍 ）
      addLearnApi ({state, commit, dispatch}, params) {
        return new Promise((resolve, reject) => {
          addLearnApi(params).then(res => {
              resolve(res)
          })
        })
      },
      // 删除学生
      deleteStudentsApi ({state, commit, dispatch}, params) {
        return new Promise((resolve, reject) => {
          deleteStudentsApi(params).then(res => {
              resolve(res)
          })
        })
      },
      // 学籍变动接口
      studentChangeApi ({state, commit, dispatch}, params) {
        return new Promise((resolve, reject) => {
          studentChangeApi(params).then(res => {
              resolve(res)
          })
        })
      },
      // 更新学生信息
      toUpdateApi ({state, commit, dispatch}, params) {
        return new Promise((resolve, reject) => {
          toUpdateApi(params).then(res => {
              resolve(res)
          })
        })
      },
      // 新增学生信息
      newStudentsApi ({state, commit, dispatch}, params) {
        return new Promise((resolve, reject) => {
          newStudentsApi(params).then(res => {
              resolve(res)
          })
        })
      },
      // 获取全部学段
      allSectionsApi ({state, commit, dispatch}, params) {
        return new Promise((resolve, reject) => {
          allSectionsApi(params).then(res => {
              resolve(res)
          })
        })
      },
      // 枚举请求
      enumerationApi ({state, commit, dispatch}, params) {
        return new Promise((resolve, reject) => {
          enumerationApi(params).then(res => {
              resolve(res)
          })
        })
      },
      // 获取学生变动记录
      changeRecordApi ({state, commit, dispatch}, params) {
        return new Promise((resolve, reject) => {
          changeRecordApi(params).then(res => {
              resolve(res)
          })
        })
      },
      // 检测登录名是否被占用
      monitorApi ({state, commit, dispatch}, params) {
        return new Promise((resolve, reject) => {
          monitorApi(params).then(res => {
            resolve(res)
          }).catch(err => {
            reject(err)
          })
        })
      },
      // 添加，修改，删除亲属关系
      handleRelativesApi ({state, commit, dispatch}, params) {
        return new Promise((resolve, reject) => {
          handleRelativesApi(params).then(res => {
            resolve(res)
          }).catch(err => {
            reject(err)
          })
        })
      },
      // 解除微信绑定
      unbindApi ({state, commit, dispatch}, params) {
        return new Promise((resolve, reject) => {
          unbindApi(params).then(res => {
            resolve(res)
          }).catch(err => {
            reject(err)
          })
        })
      },
      // 根据学段和学级获取到  当下对应年级
      correspondingGradeApi ({state, commit, dispatch}, params) {
        return new Promise((resolve, reject) => {
          correspondingGradeApi(params).then(res => {
            resolve(res.data)
          }).catch(err => {
            reject(err)
          })
        })
      }
    }
}
export default studentLists
